var app = getApp()
var ImageURL = app.globalData1.ImageURL;
var hostURL = app.globalData1.hostURL;
Page({
   data: {
      statusType: ["已完成"],
      currentType: 0,
      tabClass: ["", "", "", "", ""],
      orderList: [],
      userId: '',
   },
   statusTap: function (e) {
      var curType = e.currentTarget.dataset.index;
      this.data.currentType = curType
      this.setData({
         currentType: curType
      });
      //this.onLoad();
   },

   onLoad: function (option) {
      var that = this;
      that.setData({
         userId: option.userId,
      });
      // 获取订单列表
      wx.request({
      url: hostURL + 'sharedplatform-web/orderMaster/findOrderFinish.action',
         method: 'post',
         data: {
            userId: that.data.userId,
         },
         header: {
            'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
         },
         success: (res) => {
            //   wx.hideLoading();
            console.log(res)
            var errno = res.data.errno
            if (errno == 0) {
               console.log("订单完成查询成功")
               //if (res.data.code == 0) {
               that.setData({
                  orderList: res.data.orderListVO,
               });
               console.log(that.data.orderList)
               //}
               //  console.log(that.data.orderList)
               //  var orderId = that.data.orderList.orderId
               //  console.log(orderId)
            } else if (errno == 1) {
               console.log("改服务不在服务区")
               wx.showToast({
                  title: '您还没有完成订单',
                  content: '',
               })

            } else if (errno == 3) {
               console.log("您还没有完成订单哦亲！")
               wx.showToast({
                  title: '您还没有完成订单',
                  content: '',
               })

            }
         }
      })
   },
   
   onReady: function () {
      // 生命周期函数--监听页面初次渲染完成
   },
   onHide: function () {
      // 生命周期函数--监听页面隐藏

   },
   onUnload: function () {
      // 生命周期函数--监听页面卸载

   },
   onPullDownRefresh: function () {
      // 页面相关事件处理函数--监听用户下拉动作

   },
   onReachBottom: function () {
      // 页面上拉触底事件的处理函数

   }
})
